package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import com.netflix.appinfo.InstanceInfo;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * user 用户表 前端控制器
 * </p>
 *
 * @author xie
 * @since 2017-09-21
 */
@Controller
//@RequestMapping("/demo/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private DiscoveryClient discoveryClient;




    @RequestMapping("/userList")
    @ResponseBody
    public List<User> userList(){

        return  userService.selectList(null);
    }

    @GetMapping("/userInfo")
    @ResponseBody
    public List<ServiceInstance> showInfo(){
        return this.discoveryClient.getInstances("userDemo_1");
    }

	
}
